home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 December / CHIP Turkiye Aralık 1997.iso / internet / lsmirc61.exe / xdcc.in_ / xdcc.in
Encoding:
INI File  |  1997-09-07  |  8.0 KB  |  224 lines

  1. [script]
  2. n0=;
  3. n1=;         this section deals with XDCC
  4. n2=;
  5. n3=alias sendfile {
  6. n4=  ; file number $1 to nick $2
  7. n5=  set %file $readini $mircdirxdcc\files.ini FullPath $1
  8. n6=  set %size $readini $mircdirxdcc\files.ini Bytes $1
  9. n7=  raw -q notice $2 :Now sending $nopath(%file) ( $+ %size bytes)
  10. n8=  dcc send $2 %file
  11. n9=  xlog Send: $nopath(%file) to $2
  12. n10=  xnote 5,0Sending: $nopath(%file) to $2
  13. n11=  set %tvticks [ $+ [ [ $2 ] [ $+ [ %file ] ] ] ] $ticks
  14. n12=  set %sends $readini $mircdirxdcc\files.ini sends $nopath(%file)
  15. n13=  inc %sends
  16. n14=  writeini $mircdirxdcc\files.ini sends $nopath(%file) %sends
  17. n15=}
  18. n16=alias removetimer {
  19. n17=  %p = 0
  20. n18=  :nx
  21. n19=  inc %p
  22. n20=  if %xdccm [ $+ [ %p ] ] = $1 {
  23. n21=    %temp = 279 + %p
  24. n22=    .timer $+ %temp off
  25. n23=    %xdccm [ $+ [ %p ] ] = ""
  26. n24=  }     
  27. n25=  if %p < 10 goto nx
  28. n26=}
  29. n27=alias sendxdccmsg {
  30. n28=  %freeslots = %xdccslots - $send(0)
  31. n29=  %freequeue = %xdccqueue - %inque
  32. n30=  if (%xcheckspeed) msg $1 Slots: %freeslots of %xdccslots open, queue %freequeue $+ / $+ %xdccqueue $+ , mimimum speed %xdccmb $+ kbs
  33. n31=  else msg $1 Slots: %freeslots of %xdccslots open, queue %freequeue $+ / $+ %xdccqueue $+ , mimimum speed: none
  34. n32=  set %playto $1
  35. n33=  play -c $me $mircdirxdcc\xdccmsg.txt %linedelay
  36. n34=}
  37. n35=alias onexdccmsg {
  38. n36=  if (($left($1,1) = $chr(35)) && ($me !ison $1)) { echo 4 -a You're not on $1 $+ ! | dh }
  39. n37=  sendxdccmsg $1
  40. n38=}
  41. n39=alias doxdccmsg {
  42. n40=  if (($left($1,1) = $chr(35)) && ($me !ison $1)) { echo 4 -a Halting timer to send xdcc info to $1 (you're not there!) | removetimer $1 | dh }
  43. n41=  sendxdccmsg $1
  44. n42=}
  45. n43=alias xdccmsg {
  46. n44=  ; timed message to $1 using delay $2
  47. n45=  %i = 0
  48. n46=  :nx
  49. n47=  inc %i
  50. n48=  if %xdccm [ $+ [ %i ] ] = $null {
  51. n49=    set %xdccm [ $+ [ %i ] ] $1
  52. n50=    %temp = 279 + %i
  53. n51=    .timer $+ %temp 0 $2 doxdccmsg $1
  54. n52=  }
  55. n53=  else {
  56. n54=    if %i = 10 { echo 4 -a Sorry, you already have 10 timed xdcc messages going :( | goto end }
  57. n55=    else goto nx
  58. n56=  }
  59. n57=  :end
  60. n58=  doxdccmsg $1
  61. n59=}
  62. n60=alias loadxdccoptions {
  63. n61=  .timer967 off
  64. n62=  set %xdccmb $readini $mircdirxdcc\files.ini General Speed
  65. n63=  %xspeed = %xdccmb * 1024
  66. n64=  set %xcheckspeed $readini $mircdirxdcc\files.ini General CheckSpeed
  67. n65=  set %xlog $readini $mircdirxdcc\files.ini General Speed
  68. n66=  set %xdccslots $readini $mircdirxdcc\files.ini General Slots
  69. n67=  set %xdccqueue $readini $mircdirxdcc\files.ini General Queue
  70. n68=  if (($group(#XDCC) = on) && (%xcheckspeed)) .timer967 0 15 checkspeed
  71. n69=}
  72. n70=alias slotopen {
  73. n71=  if ($send(0) < %xdccslots) return $true
  74. n72=  return $false
  75. n73=}
  76. n74=alias qopen {
  77. n75=  if %tvquenick [ $+ [ %xdccqueue ] ] = $null return $true
  78. n76=  else return $false
  79. n77=}
  80. n78=alias addtoqueue {
  81. n79=  ; add send of file index $1 to nick $2 to first available position in queue
  82. n80=  %q = 0
  83. n81=  :nx
  84. n82=  inc %q
  85. n83=  if (%tvquenick [ $+ [ %q ] ] != $null) goto nx
  86. n84=  set %tvquenick [ $+ [ %q ] ] $2
  87. n85=  set %tvquefile [ $+ [ %q ] ] $1
  88. n86=  raw -q notice $2 :You are # $+ %q in queue
  89. n87=}
  90. n88=alias takefromque {
  91. n89=  if (($slotopen) && (%tvquenick1 != $null)) {
  92. n90=    sendfile %tvquefile1 %tvquenick1    
  93. n91=    advanceque | takefromque
  94. n92=  }
  95. n93=}
  96. n94=alias advancequeue {
  97. n95=  %q1 = 0 | %q2 = 1
  98. n96=  :nx
  99. n97=  inc %q1 | inc %q2
  100. n98=  if (%tvquenick [ $+ [ %q2 ] ] != $null) {
  101. n99=    set %tvquenick [ $+ [ %q1 ] ] %tvquenick [ $+ [ %q2 ] ]
  102. n100=    set %tvquefile [ $+ [ %q1 ] ] %tvquefile [ $+ [ %q2 ] ]
  103. n101=    raw -q notice %tvquenick [ $+ [ %q1 ] ] :Queue position: %q1
  104. n102=    goto nx
  105. n103=  }  
  106. n104=}
  107. n105=alias enablexdcc {
  108. n106=  .enable #xdcc
  109. n107=  window -a @XDCC 20 20 500 200 $mircdirxdcc\popup.txt
  110. n108=  echo 4 -a XDCC is now enabled | alert
  111. n109=  loadxdccoptions
  112. n110=}
  113. n111=alias disablexdcc {
  114. n112=  .timer167 off | window -c @XDCC
  115. n113=  if $group(#XDCC) = on echo 4 -a XDCC is now disabled
  116. n114=  else echo 4 -a XDCC is not enabled
  117. n115=  alert
  118. n116=}
  119. n117=alias xdccwin if $window(@XDCC) = $null window -an @XDCC 20 20 500 200 $mircdirxdcc\popup.txt
  120. n118=alias xnote {
  121. n119=  xdccwin
  122. n120=  if $window(@XDCC).state = minimized aline -h @XDCC $1-
  123. n121=  else aline @XDCC $1-
  124. n122=}
  125. n123=alias xlog if (%xlog) write $mircdirlogs\xdcc.log $realtime $adate $1-
  126. n124=alias checkspeed {
  127. n125=  if (($group(#XDCC) = off) || ($server = $null)) { .timer167 off | halt }
  128. n126=  %k = 0
  129. n127=  :nx
  130. n128=  inc %k
  131. n129=  if ($send(%k) != $null) {
  132. n130=    if $send(%k).cps < %xspeed {
  133. n131=      xnote 4,0Closing send(s) to $send(%k) 3,0(speed is $send(%k).cps cps)
  134. n132=      close -s $send(%k) | raw -q notice $send(%k) :Closing sends (minimum speed requirement not obtained)
  135. n133=      takefromque
  136. n134=    }
  137. n135=    goto nx
  138. n136=  }
  139. n137=}
  140. n138=alias killsends {
  141. n139=  %k = 0 | %num = 0
  142. n140=  :nx
  143. n141=  inc %k
  144. n142=  if ($send(%k) != $null) {
  145. n143=    if ($send(%k) = $1) { close -s $send(%k) | inc %num }
  146. n144=    goto nx
  147. n145=  }
  148. n146=  if %num = 0 echo 4 -a There are no sends to $1
  149. n147=  elseif %num = 1 echo 4 -a Killed 1 send to $1
  150. n148=  else echo 4 -a Killed %num sends to $1
  151. n149=}
  152. n150=alias excessxdcc {
  153. n151=  xlog Excessive requests from $1 $+ , ignoring for 5 minutes
  154. n152=  xnote Excessive XDCC requests from $1- $+ , ignoring for 5 minutes
  155. n153=  .ignore -t $mask($1,3) | .timer 1 300 .ignore -r $mask($1,3)
  156. n154=}
  157. n155=#XDCC off
  158. n156=ctcp 1:XDCC LIST:{
  159. n157=  if $ulevel < 18 {
  160. n158=    inc %xxd [ $+ [ $site ] ] | .timer 1 30 unset %xxd [ $+ [ $site ] ]
  161. n159=    if (%xxd [ $+ [ $site ] ] > 5) { excessxdcc $fulladdress | halt }
  162. n160=  }
  163. n161=  set %xnick $nick
  164. n162=  play -c $me $mircdirxdcc\xdcclst.txt 1500
  165. n163=  xnote 5,0 $+ $nick ( $+ $mask( [ $fulladdress ] ,3) $+ ) List
  166. n164=  xlog $nick ( $+ $mask( [ $fulladdress ] ,3) $+ ) List
  167. n165=}
  168. n166=ctcp 1:XDCC SEND:{
  169. n167=  if $ulevel < 18 {
  170. n168=    inc %xxd [ $+ [ $site ] ] | .timer 1 30 unset %xxd [ $+ [ $site ] ]
  171. n169=    if (%xxd [ $+ [ $site ] ] > 5) { excessxdcc $fulladdress | halt }
  172. n170=  }
  173. n171=  set %len $len($3) | dec %len
  174. n172=  set %send $right($3,%len)
  175. n173=  set %file $readini $mircdirxdcc\files.ini FullPath %send
  176. n174=  if %file = $null {
  177. n175=    xnote 4,0Erroneous Request: 3,0 $+ $3 (from $fulladdress $+ )
  178. n176=    xlog Erroneous Request: $3 (from $fulladdress $+ )
  179. n177=    raw -q notice $nick :No such file: $+ $3 $+ .
  180. n178=    halt
  181. n179=  }
  182. n180=  if ($slotopen) sendfile %send $nick
  183. n181=  elseif ($qopen) addtoqueue %send $nick
  184. n182=  else raw -q notice $nick :Slots and queue are filled; try later
  185. n183=}
  186. n184=on 1:SENDFAIL:*:{
  187. n185=  xlog Send Failed: $filename to $nick
  188. n186=  xnote 5,0Send Failed: $filename to $nick
  189. n187=  takefromque
  190. n188=}
  191. n189=on 1:GETFAIL:*:{
  192. n190=  xlog Get Failed: $filename from $nick
  193. n191=  xnote 5,0Get Failed: $filename from $nick
  194. n192=}
  195. n193=on 1:FILERCVD:*:{
  196. n194=  xlog Received: $nopath($filename) from $nick
  197. n195=  set %size $lof($filename)
  198. n196=  xnote 5,0Received: $filename from $nick ( $+ %size bytes $+ )
  199. n197=}
  200. n198=on 1:FILESENT:*:{
  201. n199=  if (%tvticks [ $+ [ [ $nick ] [ $+ [ $filename ] ] ] ] != $null) {
  202. n200=    set %size $lof($filename)
  203. n201=    set %tvticks $ticks
  204. n202=    %tvticks = $ticks - %tvticks [ $+ [ [ $nick ] [ $+ [ $filename ] ] ] ]
  205. n203=    %seconds = %tvticks / 1000
  206. n204=    %cps = %size / %seconds
  207. n205=    %kbs = %cps / 1024
  208. n206=    set %old $readini $mircdirxdcc\files.ini record $nopath($filename)
  209. n207=    if %kbs > %old writeini $mircdirxdcc\files.ini record $nopath($filename) %kbs
  210. n208=    xlog Sent: $nopath($filename) to $nick ( $+ %kbs kbs)
  211. n209=    xnote 5,0Sent: $nopath($filename) to $nick ( $+ %kbs kbs)
  212. n210=    %size = %size / 1024
  213. n211=    %sent = $readini $mircdirxdcc\files.ini General TotalSent
  214. n212=    %sent = %sent + %size
  215. n213=    writeini $mircdirxdcc\files.ini General TotalSent %sent
  216. n214=  }
  217. n215=  else {
  218. n216=    xlog Sent: $nopath($filename) to $nick
  219. n217=    xnote 5,0Sent: $nopath($filename) to $nick
  220. n218=  }
  221. n219=  takefromque
  222. n220=}
  223. n221=#XDCC end
  224.